<script setup lang="ts">
import { ref } from 'vue'

interface EmergencyPatient {
  id: string
  name: string
  status: string
  severity: string
  reportTime: string
  processed: boolean
}

const emergencyPatients = ref<EmergencyPatient[]>([
  {
    id: 'E001',
    name: '张三',
    status: '急性腹痛',
    severity: '高',
    reportTime: '10:15',
    processed: false
  },
  {
    id: 'E002',
    name: '李四',
    status: '呼吸困难',
    severity: '中',
    reportTime: '10:30',
    processed: true
  },
  {
    id: 'E003',
    name: '王五',
    status: '严重过敏',
    severity: '高',
    reportTime: '11:00',
    processed: false
  }
])

const handleEmergency = (index: number) => {
  // 处理紧急情况的逻辑
  console.log('处理紧急情况', emergencyPatients.value[index])
}
</script>

<template>
  <div class="emergency-service-container">
    <div class="emergency-card">
      <h2 class="emergency-title">紧急医疗处理</h2>
      
      <div class="emergency-table-container">
        <el-table :data="emergencyPatients" style="width: 100%" border>
          <el-table-column prop="id" label="患者ID" width="80" />
          <el-table-column prop="name" label="患者姓名" width="100" />
          <el-table-column prop="status" label="状态" width="120" />
          <el-table-column prop="severity" label="严重程度" width="100">
            <template #default="scope">
              <span :class="['severity', scope.row.severity === '高' ? 'high' : 'medium']">{{ scope.row.severity }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="reportTime" label="报告时间" width="100" />
          <el-table-column label="操作" fixed="right">
            <template #default="scope">
              <el-button 
                :type="scope.row.processed ? 'info' : 'danger'" 
                size="small" 
                :disabled="scope.row.processed"
                @click="handleEmergency(scope.$index)"
              >
                {{ scope.row.processed ? '已处理' : '立即处理' }}
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
  </div>
</template>

<style scoped>
.emergency-service-container {
  padding: 20px;
}

.emergency-card {
  background-color: #fff;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}

.emergency-title {
  font-size: 20px;
  margin-bottom: 20px;
  font-weight: bold;
  color: #333;
}

.emergency-table-container {
  border-radius: 5px;
  overflow: hidden;
}

.severity {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
}

.severity.high {
  background-color: #fef0f0;
  color: #f56c6c;
}

.severity.medium {
  background-color: #fdf6ec;
  color: #e6a23c;
}

:deep(.el-table) {
  --el-table-border-color: #ebeef5;
  --el-table-header-bg-color: #f5f7fa;
}
</style>
